/*
 * DaysheetPresenter.java
 * 
 * Copyright 2011 Matt Whipple <matt@mattwhipple.com>
 * 
 * This file is part of com.teamsuperfitness.apps
 * 
 * com.teamsuperfitness.apps is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 * 
 * com.teamsuperfitness.apps is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with com.teamsuperfitness.apps. If not, see http://www.gnu.org/licenses/.
 */

/**
 * 
 */
package com.teamsuperfitness.apps.client.presenters;

import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.teamsuperfitness.apps.client.views.ContractDetailView;
import com.teamsuperfitness.apps.client.views.ContractListView;

/**
 * @author mwhipple
 *
 */
public class DaysheetPresenter implements IPresenter {
    private final Display display;
    @SuppressWarnings("unused")
    private final SimpleEventBus eventBus;
    private final ContractListPresenter contractList;
    private final ContractDetailPresenter contractDetail;
    
    public interface Display {
        HasWidgets getListPanel();
        HasWidgets getDetailPanel();
        Widget asWidget();
    }
    
    public DaysheetPresenter(SimpleEventBus eventBus, Display view) {
        this.eventBus = eventBus;
        this.display = view;
        contractList = new ContractListPresenter(eventBus, new ContractListView());
        contractDetail = new ContractDetailPresenter(eventBus, new ContractDetailView());
    }
    
    /* (non-Javadoc)
     * @see com.teamsuperfitness.apps.client.presenters.IPresenter#go(com.google.gwt.user.client.ui.Panel)
     */
    public void go(HasWidgets container) {
        container.clear();
        container.add(this.display.asWidget());
        contractList.go(display.getListPanel());
        contractDetail.go(display.getDetailPanel());
    }
}
